package test.yzx.pproject.act4;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

public class DialogView {


    private final Activity mActivity;
    private final ViewGroup mDecorView;
    private FrameLayout mWrapperView;
    private View mContentView;


    public DialogView(Activity activity){
        mActivity = activity;
        mDecorView = (ViewGroup) mActivity.getWindow().getDecorView();
    }


    public void show(View view){
        if(mWrapperView!=null)
            throw new IllegalStateException("dialog has showing");
        mWrapperView = new FrameLayout(mActivity);
        mWrapperView.setLayoutParams(new ViewGroup.LayoutParams(-1, -1));
        mDecorView.addView(mWrapperView);
        mWrapperView.addView(view);
        mContentView = view;
    }

    public FrameLayout getWrapperView() {
        return mWrapperView;
    }

    public View getContentView() {
        return mContentView;
    }

    public void remove(){
        mDecorView.removeView(mWrapperView);
    }

}
